<?php

namespace app\controller\api;

use app\base\BaseEncryptController;
use app\factory\Pay as PayFactory;
use think\Request;

/**
 * Pay 支付
 * Class Pay
 * @package app\controller
 */
class Pay extends BaseEncryptController
{
    protected function initialize()
    {
        parent::initialize();
    }

    /**
     * 支付订单展示
     * @param Request $request
     * @return \think\response\Json
     */
    public function onPayOrderShow(Request $request)
    {
        $formData = $request->param();
        $userInfo = $this->currentUser;//登录信息
        $PayFactory = new PayFactory();
        $res = $PayFactory->payPriceShow($formData, $userInfo);
        return self::returnMsg($res);
    }


    /**
     * 确认支付
     * @param Request $request
     * @return \think\response\Json
     */
    public function onConfirmPay(Request $request)
    {
        $formData = $request->param();
        $userInfo = $this->currentUser;//登录信息
        $PayFactory = new PayFactory();
        $res = $PayFactory->ConfirmPay($formData, $userInfo);
        return self::returnMsg($res);
    }

    /**
     * 查询支付结果
     * @param Request $request
     * @return \think\response\Json
     * @throws \think\Exception
     */
    public function payQuery(Request $request)
    {
//      string $formData[pay_sn] 我的支付编号
//      int $formData[price] 支付金额
        $formData = $request->param();
        $PayFactory = new PayFactory();
        $res = $PayFactory->payQuery($formData);
        return self::returnMsg($res);
    }

}
